<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="../resources/orientation-event-helpers.js"></script>
<script>
'use strict';

promise_test(async (t) => {
  const helper = new SensorTestHelper(t, 'devicemotion');
  await helper.grantSensorsPermissions();
  await helper.initializeSensors();

  const motionData1 = generateMotionData(1, 2, 3,
                                         4, 5, 6,
                                         7, 8, 9);
  await helper.setData(motionData1);
  await Promise.all([
    waitForEvent(getExpectedMotionEvent(motionData1)),
    waitForEvent(getExpectedMotionEvent(motionData1))
  ]);

  const motionData2 = generateMotionData(11, 12, 13,
                                         14, 15, 16,
                                         17, 18, 19);
  await helper.setData(motionData2);
  await waitForEvent(getExpectedMotionEvent(motionData2));
}, 'Tests using multiple event handlers for the Device Motion API.');
</script>
